package No_1.Visitor;

import java.util.Scanner;

/**
 * @Author MDD
 * @Description
 * @Version
 * @Date
 **/
public class Visitor {
    int age;

    public int buy(){
        if (age>=18&&age<=60){
            return 20;
        }
        else {
            return 0;
        }
    }

    public static void main(String[] args) {

        Visitor ming = new Visitor();

        Scanner sc = new Scanner(System.in);


        for (int i = 0; i < 50; i++) {
            System.out.print("请输入您的姓名：");
            String name = sc.next();
            System.out.print("请输入您的年龄：");
            ming.age = sc.nextInt();

            int price = ming.buy();

            System.out.print(name+"的年龄为："+ming.age+"岁，"+"\t票价为："+price+"元。");
            System.out.print("\n\n");
            System.out.print("是否继续购票（y/Y(是)|n/N（否））:");
            String jixu = sc.next();
            if (!"y".equalsIgnoreCase(jixu)){
                break;
            }
        }
        System.out.println("退出程序！");

    }




}
